package com.rongxun.utils;

import android.app.Activity;
import android.content.Context;

/**
 * 创建者     庄丰泽
 * 创建时间   2018/6/26 18:30
 * 描述
 */
public class HttpUiTips {
    /**
     * showDialog & dismissDialog 在http 请求开始的时候显示，结束的时候消失
     * 当然不是必须需要显示的 !
     */
    public static void showDialog(final Context mContext, final boolean canceledOnTouchOutside, final String messageText) {
        if (mContext == null || !(mContext instanceof Activity) || ((Activity) mContext).isFinishing())
            return;
        ((Activity) mContext).runOnUiThread(new Runnable() {
            @Override
            public void run() {
                HttpDialogUtils.showDialog(mContext, canceledOnTouchOutside, messageText);
            }
        });
    }

    public static void dismissDialog(final Context mContext) {
        if (mContext == null || !(mContext instanceof Activity) || ((Activity) mContext).isFinishing())
            return;             //maybe not good !
        if (mContext != null) {
            ((Activity) mContext).runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    HttpDialogUtils.dismissDialog();
                }
            });
        }
    }
}
